﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Utils 的摘要说明
/// </summary>
public class Utils
{
    public static T FindControl<T>(Control containerctl, int startidx) where T:class
    {
        int i = 0;
        foreach (Control c in containerctl.Controls)
        {
            if (c is Literal) continue;
            if (c is T)
            {
                if (i >= startidx) return c as T;
            }
            else
            {
                i++;
                continue;
            }
        }
        return null;
    }

    public static bool CheckBizLocker(string key)
    {
        object o= HttpContext.Current.Application["BizLocker_"+key];
        return (null != o) &&(((DateTime)o).AddMinutes(2) > DateTime.Now);
    }
    public static void SetBizLocker(string key,bool set)
    {
        if (set) HttpContext.Current.Application["BizLocker_" + key] = DateTime.Now;
        else HttpContext.Current.Application.Remove("BizLocker_" + key);
    }

}

